package com.api.dispose.enums;

import lombok.Getter;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 李大牛家的牛 (scafel@163.com)
 * @createDate 2025/5/20-14:52
 * @description ToDo...
 **/
@Getter
public enum FileTypeEnums {

    IMAGE(1, "图片"),
    VIDEO(2, "视频"),
    AUDIO(3, "音频"),
    DOCUMENT(4, "文档"),
    UNKONWN(0, "未知")
    ;


    private static final Map<Integer, FileTypeEnums> codeToEnumMap = new ConcurrentHashMap<>();
    private static final Map<Integer, String> enumMap = new ConcurrentHashMap<>();

    static {
        for (FileTypeEnums type : FileTypeEnums.values()) {
            codeToEnumMap.put(type.getCode(), type);
            enumMap.put(type.getCode(), type.getMessage());
        }
    }

    private final int code;
    /**
     * 自定义描述
     **/
    private final String message;

    FileTypeEnums(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static FileTypeEnums getType(int code) {
        FileTypeEnums type = codeToEnumMap.get(code);
        if (type == null) {
            return FileTypeEnums.UNKONWN;
        }
        return type;
    }

    /**
     * 获取枚举类中所有的枚举值
     * @return Map
     */
    public Map<Integer, String> getEnumsMap() {
        return enumMap;
    }
}
